home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
jpi
/
filefunc.bas
< prev
next >
Wrap
BASIC Source File
|
1998-01-22
|
2KB
|
64 lines
Attribute VB_Name = "FileFunctions"
Function GetPropertyValueFromFile(Filename$, ValuePropertyName$)
On Error GoTo NotFound
Open Filename$ For Input As #1
Do
Line Input #1, a$
If a$ = "[ENDOFFILE]" Then Exit Do
If MiscFunctions.GetPropertyName(a$) = ValuePropertyName$ Then
GetPropertyValueFromFile = MiscFunctions.GetPropertyValue(a$)
Exit Do
End If
Loop
Close #1
NotFound:
Exit Function
End Function
Sub OpenGameFile(Filename$, Filenumber)
If Dir(Filename$) = Filename$ Then
Call OpenFile(Filename$, Filenumber)
ElseIf Dir(Directory_GameData & Filename$) = Filename$ Then
Call OpenFile(Directory_GameData & Filename$, Filenumber)
Else
'File is not found in the directory
Call OpenFile(Directory_GameData & GameEngine.GameDataFile$, Filenumber)
Call FindFileEntry(Filename$, Filenumber)
End If
End Sub
Private Sub OpenFile(Filename$, Filenumber)
Select Case Filenumber
Case 1
Open Filename$ For Input As #1
Case 2
Open Filename$ For Input As #2
Case 3
Open Filename$ For Input As #3
Case 4
Open Filename$ For Input As #4
End Select
End Sub
Private Sub FindFileEntry(Filename$, Filenumber)
Do
a$ = GetLineFromFile(Filenumber)
If a$ = "[FILE]" Then
a$ = GetLineFromFile(Filenumber)
If MiscFunctions.GetPropertyValue(a$) = UCase$(Filename$) Then
Exit Do
End If
End If
Loop
End Sub
Public Function GetLineFromFile(Filenumber)
Select Case Filenumber
Case 1
Line Input #1, GetLineFromFile
Case 2
Line Input #2, GetLineFromFile
Case 3
Line Input #3, GetLineFromFile
Case 4
Line Input #4, GetLineFromFile
End Select
End Function